package distributed;

import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Date;

import xml.Message;

/**
 * A simple I/O to record all messages that pass through the DLSProtocolFactory,
 * for debugging purposes.
 * @author Marcus Menghini
 *
 */
public class LogWriter {
	
	/** A PrintStream to a text file for easy Message I/O debugging */
	static PrintStream out;
	
	static {
		try {
			out = new PrintStream("decisionlines_log.txt");
		} catch (FileNotFoundException fnfe) {}
	}

	/**
	 * writes to the log.
	 */
	public static void writeToLog(Message m) {
		out.println(new Date().toString() + ": " + m.toString().substring(38));
		if (m.toString().contains("</response>"))
			out.println();
	}
	
}
